import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'

const req = require.context('./modules', false, /\.js$/)
// ['app', 'settings', 'user']
const mName = req.keys().map(item => item.split('./')[1]).map(item => item.split('.js')[0])
const mModule = req.keys().map(req) // [module,module,moduel]

const obj = {}
mName.forEach((key, index) => {
  obj[key] = mModule[index].default
})
console.log(obj)
Vue.use(Vuex)

const store = new Vuex.Store({
  modules: obj,
  getters
})

export default store
